package com.micro.service.exception;

import com.micro.service.entity.ResponseMessage;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

/**
 * Create by Vic Xu on 2019/3/12
 */
@RestControllerAdvice
public class CommonExcaptionHandler {


    @ExceptionHandler(Exception.class)
    public ResponseMessage<String> exceptionHandler(HttpServletRequest request, Exception exception) {
        return handlerExceptionDetailInfo(request, exception);
    }

    private ResponseMessage<String> handlerExceptionDetailInfo(HttpServletRequest request, Exception exception) {
        return ResponseMessage.exception(-1, exception.getClass().getName(), exception.getMessage());
    }

}
